<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" />
    <button>判断成绩</button>
  </body>
</html>
<script>
  var oIpt = document.querySelector("input");
  var oBtn = document.querySelector("button");
  oBtn.onclick = function () {
    if (oIpt.value.trim() == "") return alert("请输入内容");
    if (isNaN(oIpt.value)) return alert("请输入数字");
    if (oIpt.value > 100 || oIpt.value < 0) return alert("请输入0-100内的数字");
    if (oIpt.value > 90) {
      alert("优秀");
    } else if (oIpt.value >= 80) {
      alert("良好");
    } else if (oIpt.value >= 60) {
      alert("及格");
    } else if (oIpt.value > 0) {
      alert("不及格");
    }
  };
</script>
